package cn.tedu.search.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

import cn.tedu.search.service.SearchService
import cn.tedu.staticResources.ComRe

@RestController
@RequestMapping(Array("search/manage/"))
class SearchController {

  @Autowired
  private var searchService: SearchService = _

  //创建批量索引
  @RequestMapping(Array("create"))
  def createIndex = { searchService.createIndex("emindex"); ComRe.success }

  //搜索功能
  @RequestMapping(Array("query"))
  def search(query: String, page: Int, rows: Int) = searchService.search(query, page, rows)

}